package sismed.gui.comando;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import sismed.exception.DAOException;
import sismed.negocio.fachada.Fachada;
import sismed.negocio.modelo.Exame;

public class ComandoRealizarExameHematologico extends ComandoGenerico {

	@Override
	public void executar(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		if( request.getSession().getAttribute("tipoUsuario").equals( null ) )				
			response.sendRedirect("login.jsp");
		else{
			Fachada fachada = Fachada.getInstance();
			String id = request.getParameter("id");
			
			try {	
				Exame exame = fachada.recuperarExame(id);
				request.setAttribute("Exame", exame);
				request.getRequestDispatcher("CadastrarResultadoHematologico.jsp").forward(request, response);	
			} 
			catch (DAOException e) {
				response.sendRedirect("erro.jsp?msgerro=Erro ao recuperar mensagens.");	
			}
		}
	}
}
